package four;

import com.fasterxml.jackson.databind.ObjectMapper;
import four.model.SplitBean;

import java.io.IOException;
import java.net.URL;

public class SplitConfigurationExample {
    public static void main(String[] args) throws IOException {
        URL resource = SplitConfigurationExample.class.getClassLoader().getResource("four/splitBean.json");

        ObjectMapper mapper = new ObjectMapper();

        // 字符串解析成对象
        SplitBean splitBean = mapper.readValue(resource, SplitBean.class);

        //SplitBean{name='SHANGHAI', password='12345'}
        System.out.println(splitBean);

        String s = mapper.writeValueAsString(splitBean);

        //{"name":"SHANGHAI"}
        System.out.println(s);


    }
}
